<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>8.体验echarts绘制柱状图</title>
</head>
<body>
  <div id="main" style="width:800px;height:600px"></div>
  <script src="./echarts/echarts.min.js"></script>
  <script>
    // 1. 获取页面中的标签对象
    const main = document.getElementById('main');
    // 2. 使用echarts的init方法进行初始化 
    // 只要是页面中引入了echarts框架,就会提供一个echarts的对象
    const myChart = echarts.init(main);

    // 3. 准备参数
    const option = {
      title: {
        text: 'ECharts 入门示例',
        textStyle: {
          color: 'red'
        }
      },
      tooltip: {},
      legend: {
        data: ['销量']
      },
      xAxis: {
        data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子','电子产品']
      },
      yAxis: {},
      series: [
        {
          name: '销量',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20,37]
        }
      ]
    };
    // 4. 根据参数生成图形
    myChart.setOption(option)
  </script>
</body>
</html>